#include <stdio.h>
#include <stdlib.h>

struct node {
 struct node *next;
 int value;
};

struct node *top = NULL;

void push(int item)
{
  struct node *tmp2;  
  //FIX
  //tmp2 = malloc(sizeof(struct node));
  /*if (!tmp2) { 
    assert(0);
    return; 
  }*/
  
  tmp2->value = item;
  tmp2->next = top;
  top = tmp2;
}

int pop() {
  int returnVal = 0;
  
  if(top != NULL) {
    returnVal = top->value;
    struct node *tmp;
    tmp = top;
    top = top->next;
    //FIX
    //free(tmp);
  }
  
  return returnVal;
}

void printStack() {
  printf("Printing Stack\n");
  struct node *tmp;
  tmp = top;
  while(tmp!=NULL) {
    printf("%d\n", tmp->value);
    tmp = tmp->next;
  }
}

void runTest() {
  int i;
  for(i = 0; i <1000; i++) {
    push(i);
    if((i % 4) == 0) {
      pop();
    }
  }
}

int main(void) {
  runTest();
  printStack();
}